package com.meitianhui.convenitenbuy.module.mine.http;

/*
 *  @项目名：  ConvenientPurchase 
 *  @包名：    com.meitianhui.convenitenbuy.module.mine.http
 *  @文件名:   MineApiDataSource
 *  @创建者:   amy
 *  @创建时间:  2017/11/5 下午3:58
 *  @描述：
 */

import com.meitianhui.convenitenbuy.base.BaseArrayResponse;
import com.meitianhui.convenitenbuy.base.BaseResponse;
import com.meitianhui.convenitenbuy.http.RetrofitHelper;
import com.meitianhui.convenitenbuy.module.mine.model.CollectedStoresBean;
import com.meitianhui.convenitenbuy.module.mine.model.ConsumerAddress;
import com.meitianhui.convenitenbuy.module.mine.model.GroupBean;
import com.meitianhui.convenitenbuy.module.mine.model.GroupDetailBean;
import com.meitianhui.convenitenbuy.module.mine.model.HXUserBean;
import com.meitianhui.convenitenbuy.module.mine.model.ShopGuiderBean;
import com.meitianhui.convenitenbuy.module.mine.model.ShoppersHistoricalBean;
import com.meitianhui.convenitenbuy.module.mine.model.StoreImageBean;
import com.meitianhui.convenitenbuy.module.mine.model.UserPaySmsVerifyResponse;
import com.meitianhui.convenitenbuy.module.mine.model.UserPhotoResponse;
import com.meitianhui.convenitenbuy.module.mine.model.UserUrlBean;
import com.meitianhui.convenitenbuy.module.order.model.bean.EmptyInfo;
import com.meitianhui.convenitenbuy.module.store.model.StoreInfo;
import com.meitianhui.convenitenbuy.util.RxUtils;

import java.util.List;

import okhttp3.MultipartBody;
import retrofit2.http.Part;
import retrofit2.http.Query;
import rx.Observable;

public class MineApiDataSource implements MineApi {
    private static volatile MineApiDataSource instance = null;
    private MineApiDataSource(){}
    public static MineApiDataSource getInstance() {
        if (instance == null) {
            synchronized (MineApiDataSource.class) {
                if (instance == null) {
                    instance = new MineApiDataSource();
                }
            }
        }
        return instance;
    }
    @Override
    public Observable<UserPhotoResponse> uploadHeadImg(@Part("app_token") String appToken, @Part("category") String ossCommunity, @Part("subffix") String subffix, @Part("up_load_file") String fileName, @Part MultipartBody.Part image) {
        return RetrofitHelper.createApi(MineApi.class).uploadHeadImg(appToken, ossCommunity, subffix, fileName, image).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<List<StoreImageBean>> getHeadImg(@Part("app_token") String appToken, @Part("doc_ids") String docId) {
        return RetrofitHelper.createApi(MineApi.class).getHeadImg(appToken,docId).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<Object> upDateUserInfo(@Part("app_token") String appToken, @Part("service") String service, @Part("params") String jsonDate) {
        return RetrofitHelper.createApi(MineApi.class,true,0).upDateUserInfo(appToken,service,jsonDate).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<UserPaySmsVerifyResponse> getSmsCode(@Query("app_token") String appToken, @Query("service") String service) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getSmsCode(appToken,service).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> getPhoneVerifyCode(@Query("app_token") String appToken, @Query("mobile") String mobile, @Query("lock_value") String lockValue) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getPhoneVerifyCode(appToken,mobile,lockValue).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<EmptyInfo> submitPasswordSetting(@Query("user_token") String userToken, @Query("payment_password") String passWord, @Query("mobile") String number, @Query("sms_code") String smsCode) {
        return RetrofitHelper.createApi(MineApi.class,true,1).submitPasswordSetting(userToken,passWord,number,smsCode).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<Object> payWithoutPwAndSmsNotify(@Query("user_token") String userToken, @Query("small_direct") String noPw, @Query("sms_notify") String smsNotify) {
        return RetrofitHelper.createApi(MineApi.class,true,1).payWithoutPwAndSmsNotify(userToken,noPw,smsNotify).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<ConsumerAddress> getUserReceivingAddress(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getUserReceivingAddress(appToken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<Object> notifyOrAddReceivingAddress(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).notifyOrAddReceivingAddress(appToken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<Object> logOut(@Query("user_token") String user_tocken) {
        return RetrofitHelper.createApi(MineApi.class,true,1).logOut(user_tocken).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> bindRecommender(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).bindRecommender(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<EmptyInfo> upLoadFadeBack(@Query("user_token") String user_tocken, @Query("category") String category, @Query("contact") String contact, @Query("data_source") String data_sourse, @Query("desc1") String desc1, @Query("attachment") String attachment) {
        return RetrofitHelper.createApi(MineApi.class,true,1).upLoadFadeBack(user_tocken,category,contact,data_sourse,desc1,attachment).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<CollectedStoresBean>> getUserCollectionStore(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getUserCollectionStore(appToken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> collectStore(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String jsonDate) {
        return RetrofitHelper.createApi(MineApi.class,true,0).collectStore(appToken,service,jsonDate).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseArrayResponse<String>> getSystemNotify(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getSystemNotify(appToken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseArrayResponse<GroupBean>> getMsgGroup(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getMsgGroup(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseArrayResponse<GroupDetailBean>> getMsgGroupDetail(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getMsgGroupDetail(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseArrayResponse<UserUrlBean>> getMsgGroupMember(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getMsgGroupMember(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<HXUserBean>> getMsgSingle(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getMsgSingle(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<ShopGuiderBean>> getShopGuider(@Query("user_token") String user_tocken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getShopGuider(user_tocken,service,page,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<ShoppersHistoricalBean>> getGuiderHistory(@Query("user_token") String user_tocken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).getGuiderHistory(user_tocken,service,page,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> deleteShopGuider(@Query("user_token") String user_tocken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,1).deleteShopGuider(user_tocken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreInfo>> getDefaultSearchStore(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getDefaultSearchStore(appToken,service,params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<StoreInfo>> getSearchStores(@Query("app_token") String appToken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(MineApi.class,true,0).getSearchStores(appToken,service,page,params).compose(RxUtils.rxSchedulerHelper());
    }


}
